﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Business;
using System.Web.Configuration;
using Domain;

namespace HotelBrisaYArenaAdministrador
{
    public partial class GenerarReservacion : System.Web.UI.Page
    {
        ReservacionBusiness resBusbiness = new ReservacionBusiness(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        HabitacionBusiness habBusiness = new HabitacionBusiness(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        TipoHabitacionBusiness tipoHabBusiness = new TipoHabitacionBusiness(WebConfigurationManager.ConnectionStrings["ApplicationServices"].ToString());
        Reservacion reservacion = new Reservacion();
        Random r = new Random();
        int numero;
        Habitacion hab = new Habitacion();
        TipoHabitacion tipoHab = new TipoHabitacion();
        int idReservacion;


        protected void Page_Load(object sender, EventArgs e)
        {
            idReservacion = Int32.Parse(Request.QueryString["id"].ToString());
            reservacion = resBusbiness.RecuperaReservacionXID(idReservacion);
            DetalleReservacion detalle = resBusbiness.RecuperaDetalleReservacionXID(idReservacion);
            reservacion.DetalleReservacion = detalle;
            numero = r.Next(100000000, 999000000);
            DateTime fechaActual = DateTime.Today;
            lblFecha.Text = fechaActual.ToString();
            lblId.Text = reservacion.IdReservacion.ToString();
            lblNombre.Text = reservacion.NombreCliente;
            lblApellidos.Text = reservacion.ApellidosCliente;
            lblEmail.Text = reservacion.Email;
            lblTarjeta.Text = reservacion.TarjetaCredito;
            lblTransaccion.Text = numero.ToString();
            lblFechaLlegada.Text = reservacion.DetalleReservacion.FechaLlegada.ToString();
            lblFechaSalida.Text = reservacion.DetalleReservacion.FechaSalida.ToString();
            hab = habBusiness.ObtenerHabitacion(reservacion.IdHabitacion);
            tipoHab = tipoHabBusiness.ObtenerTipoHabitacion(hab.TipoHabitacion.IdTipoHab);
            lblTipo.Text = tipoHab.Tipo;
        }

        protected void btnGenerarReporte_Click(object sender, EventArgs e)
        {

        }

        protected void btnEliminarRes_Click(object sender, EventArgs e)
        {
            Session["Reservacion"] = reservacion;
            Response.Redirect("EliminarReservacion.aspx");
        }
    }
}